<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <textarea id="" cols="40" rows="15" v-model="content"></textarea>
      <button @click="add">发布评论</button>
      <table border="1" cellpadding="10" cellspacing="0">
        <thead>
          <tr>
            <th>游客</th>
            <th>评论</th>
            <th>点赞数</th>
            <th>发布日期</th>
            <th colspan="3">操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item,index) in list" :key="item.id">
            <td>{{item.name}}</td>
            <td>{{item.content}}</td>
            <td>{{item.count}}</td>
            <td>{{item.time}}</td>
            <td>
              <button @click="item.count++">点赞</button>
            </td>
            <td>
              <button @click="list.unshift(...list.splice(index,1))">
                置顶
              </button>
            </td>
            <td>
              <button @click="list.splice(index,1)">删除</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </body>
</html>
